<!DOCTYPE html>
<html>
<head>
    <include file="./Public/html/_head.html"/>
</head>
<body id="body" ontouchstart>
    <include file="./Public/html/_refresh.html"/>
    <header class='demos-header'>
        <h1 class="demos-title">发布签到</h1>
    </header>
    <div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">签到名称</label></div>
            <div class="weui_cell_bd weui_cell_primary" id="signinName">
                {$time|default="签到"}
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label for="" class="weui_label">截止时间</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input id="time" class="weui_input" type="datetime-local" value="" placeholder="">
            </div>
        </div>
    </div>

    <div class="weui_btn_area">
        <a class="weui_btn weui_btn_primary" href="javascript:" id="submit">确定</a>
    </div>
    <div id="test"></div>
</body>
<include file="./Public/html/_foot.html"/>
<include file="./Public/html/_refreshJs.html"/>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
    wx.config({
        debug: false,
        appId: '{$signPackage.appId}',
        timestamp: {$signPackage.timestamp},
        nonceStr: '{$signPackage.nonceStr}',
        signature: '{$signPackage.signature}',
        jsApiList: [
        'getLocation',
        ]
    });


    var latitude = '';
    var longitude= '';
    var accuracy = '';

    $.showLoading('正在获取地理位置');
    wx.ready(function(){
        wx.getLocation({
            success:function(res){
                latitude = res.latitude;
                longitude = res.longitude;
                accuracy = res.accuracy;
                $.hideLoading();
            }
        });
    });
    setTimeout(function(){
        $.hideLoading();
    },2000);

    $('#submit').click(function(){
        signinName = $('#signinName').html();
        deadtime   = $('#time').val();
        if (deadtime == '')
            $.toptip('请选择签到截止时间');
        else if(latitude == '' || longitude == '' || accuracy == '') 
            $.toptip('请重新获取本页面，以获取地理位置信息');
        else{
            window.location.href="{:U('signin_chose_class')}/latitude/"+latitude+"/longitude/"+longitude+"/accuracy/"+accuracy+"/deadtime/"+deadtime;
        }
    });
</script>
</html>

